package com.atguigu.day17.collection02.c1;

import org.junit.Test;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;

/**
 * @version 1.0
 * @Author 马冰
 * @Date 2024/11/20 11:43
 * @注释
 */
public class StudentTest {
    @Test
    public void test01(){
        Student s0 = new Student("张三",58);
        Student s1 = new Student("李四",99);
        Student s2 = new Student("王五",66);
        Student s3 = new Student("赵六",32);
        Student s4 = new Student("孙七",87);
        Student s5 = new Student("老八",68);

        Collection<Student> students = new ArrayList<Student>();
        students.add(s0);
        students.add(s1);
        students.add(s2);
        students.add(s3);
        students.add(s4);
        students.add(s5);

        for(Student stu : students){
            System.out.println(stu);
        }

        Iterator<Student> iter = students.iterator();
        while(iter.hasNext()){
            Student next = iter.next();
            if (next.getScore() < 60){
                iter.remove();
            }
        }

    }
}
